﻿using Common;
using Dapper;
using Model.Request;
using Model.Response;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dal
{
    public class NoticeDAL
    {
        /// <summary>
        /// 公告列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public List<ResNotice> AppNoticeShow(NoticeRequest request)
        {
            var dp = new DynamicParameters();
            dp.Add("@UserCode", request.UserCode);
            dp.Add("@CoID ", request.CoID);
            dp.Add("@PageIndex ", request.PaperIndex);
            using (IDbConnection conn = daconn.GetConnection())
            {
                var userinfo = conn.Query<ResNotice>("prAppNoticeShow", dp, null, true, null, CommandType.StoredProcedure).ToList();
                return userinfo;
            }
        }
        public bool AppNoticeInsert(AddNoticeRequest request)
        {
            var dp = new DynamicParameters();
            dp.Add("@Remark", request.Remark);
            dp.Add("@UserCode", request.UserCode);
            dp.Add("@CoID", request.CoID);
            dp.Add("@Message", "", DbType.String, ParameterDirection.Output);
            using (IDbConnection conn = daconn.GetConnection())
            {
                return  conn.Execute("prAppNoticeInsert", dp, null, null, CommandType.StoredProcedure) > 0; 
            }
        }
    }
}
